<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Grid布局</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body {
      padding: 10px;
    }

    .container {
      display: grid;
      gap: 20px;
      /* grid-template-columns: 100px 100px 100px;
      grid-template-rows: 100px 100px 100px 100px; */

      /* grid-template-columns: 33.3% 33.3% 33.3%;
      grid-template-rows: 100px 100px 100px 100px; */

      /* grid-template-columns: repeat(3, 33.3%);
      grid-template-rows: repeat(4, 100px); */

      /* grid-template-columns: repeat(auto-fill, 100px);
      grid-template-rows: repeat(100, 100px); */

      /* grid-template-columns: 1fr 2fr;
      grid-template-rows: repeat(100, 100px); */

      /* grid-template-columns: 1fr minmax(100px, 1fr) 1fr;
      grid-template-rows: repeat(4, 100px); */

      /* grid-template-columns: repeat(12, 1fr); */

      /* grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); */

      /* grid-template-columns: repeat(3, 100px);
      grid-template-rows: repeat(6, 100px); */

      /* grid-auto-flow: column dense; */
      /* justify-items: stretch; */

      /* justify-content: center; */

      /* grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      grid-template-rows: 100px;
      grid-auto-rows: 100px; */

      grid-template-columns: repeat(3, 1fr);
      grid-template-rows: 100px;
      grid-auto-rows: 100px;




    }

    span {
      padding: 5px;
      border-radius: 5px;

      /* width: 100px; */
    }

    span:first-child {
      /* grid-row-start: 1;
      grid-row-end: 3;
      grid-column-start: 2;
      grid-column-end: 3; */

      /* grid-column-start: span 2; */

      /* grid-column: 1 / 3;
      grid-row: 1 / 3; */

      grid-area: 1/1/4/3;
    }
  </style>
</head>

<body>
  <div class="container" id="div">

  </div>


  <script>
    let $div = document.querySelector("#div")
    let colors = ['red', 'orange', 'green', 'blue', 'yellow', 'gray', 'teal', 'pink']
    let content = ''
    for (let index = 0; index < 17; index++) {
      content += `<span style='background-color: ${colors[index % colors.length]}'>${index}</span>`
    }
    $div.innerHTML = content
  </script>
</body>

</html>